<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'findReimburse.jsp' starting page</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<script type="text/javascript" src="<%=basePath%>manage/js/jquery.js"></script>
		<script language="javascript" type="text/javascript" src="datemaker/WdatePicker.js"></script>
		<script type="text/javascript" src="manage/js/addbg.js"></script>
		<link rel="stylesheet" type="text/css" href="manage/css/guanli.css"></link>
		<link rel="stylesheet" type="text/css" href="manage/css/search.css"></link>
	</head>

	<body>
		<div class="main" >
		<h2 class="tableTitle">报销展示</h2>
		<table class="search">
		<tr>
			<!-- 按个人搜索 -->
			<s:form action="findReimburseById" method="get">
					<td rowspan="2"><strong>按个人搜索</strong></td>
					<td rowspan="2">员工编号:
							<s:textfield name="staffId" value="%{staffId}" size="5"></s:textfield>
					</td>
					<td rowspan="2"><s:submit value="查询"></s:submit>
									<s:hidden name="page.currentPage" value="1"></s:hidden>
									<s:hidden name="page.pageSize" value="10"></s:hidden>&nbsp;
					</td>
			</s:form>
			
			<!-- 按时间汇总 -->
			<s:form action="findReimburseByDate" method="get">
			<td rowspan="2"><strong>按时间汇总</strong></td>
			<td >开始时间:
					  <input type="text" name="start" class="Wdate"
					  value="<s:date name="start" format="yyyy-MM-dd"/>"
					  onClick="WdatePicker()" /><br/>
				结束时间:
					<input type="text" name="end" class="Wdate"
						   value="<s:date name="end" format="yyyy-MM-dd"/>"
							onClick="WdatePicker()" />
			</td>
			<td rowspan="2"><s:hidden name="page.currentPage" value="1"></s:hidden>
							<s:hidden name="page.pageSize" value="10"></s:hidden>
							<s:submit value="查询"></s:submit>&nbsp;
			</td>
			</s:form>
			
			<!-- 按月份汇总 -->
			<s:form action="findReimburseByMonth" method="get">
			<td rowspan="2"><strong>按月份汇总</strong></td>
			<td ><span style="margin: 0 45px 0 0;">年份:</span>
							<select name="year" style="margin: 0 45px 0 0;">
								<%
									Calendar calendar = Calendar.getInstance();
										int nowYear = calendar.get(Calendar.YEAR);
										for (int i = 2000; i <= nowYear; i++) {
								%>
								<option value="<%=i%>"
									<%Object yearObj = request.getAttribute("year");
					String year = null;
					if (yearObj != null)
						year = yearObj.toString();
					if (year != null && i == new Integer(year)) {%>
									selected="selected" <%}%>>
									<%=i%>
								</option>
								<%
									}
								%>
							</select><br/>
				<span style="margin: 0 45 0 0">月份:</span>
							<s:select cssStyle="margin:0 45 0 0" name="month"
								list="#{1:'1月',2:'2月',3:'3月',4:'4月',5:'5月',6:'6月',7:'7月',8:'8月',9:'9月',10:'10月',11:'11月',12:'12月'}"></s:select>
			</td>
			<td rowspan="2"><s:hidden name="page.currentPage" value="1"></s:hidden>
							<s:hidden name="page.pageSize" value="10"></s:hidden>
							<s:submit value="查询"></s:submit>&nbsp;
			</td>
			</s:form>
			<td rowspan="2"><input type="button" value="添加报销信息"
							onclick="window.location.assign('<%=basePath%>manage/reimburse/addReimburse.jsp')" /></td>
		</tr>
		</table>
	
			
			
			
			<table class="cssrain">
				<thead>
				<tr>
					<th>员工编号</th>
					<th>员工姓名</th>
					<th>类型</th>
					<th>开始时间</th>
					<th>结束时间</th>
					<th>报销金额</th>
					<th>是否需要上交发票</th>
					<th>应交发票金额</th>
					<th>已经发票金额</th>
					<th>欠交发票金额</th>
					<th>报销状态</th>
				</tr>
				</thead>
				<tbody>
				<s:if test="reimburseList != null && !reimburseList.isEmpty()">
					<s:iterator value="reimburseList">
					<tr
						<s:if test="notpaid > 0">
						style="background-color:yellow;color:red;"
					</s:if>>
						<td>
							<s:property value="staff.staffId" />
						</td>
						<td>
							<s:property value="staff.name" />
						</td>
						<td>
							<s:property value="typeByTypeId.name" />
						</td>
						<td>
							<s:property value="start" />
						</td>
						<td>
							<s:property value="end" />
						</td>
						<td>
							<s:property value="amount" />
						</td>
						<td>
							<s:if test="typeByHandIn.id == 0">否</s:if>
							<s:elseif test="typeByHandIn.id == 1">是</s:elseif>
						</td>
						<td>
							<s:property value="payable" />
						</td>
						<td>
							<s:property value="paid" />
						</td>
						<td>
							<s:property value="notpaid" />
						</td>
						<td>
							<s:if test="typeByStatus.id == 0">未报销</s:if>
							<s:elseif test="typeByStatus.id == 1">已报销</s:elseif>
						</td>
					</tr>
				</s:iterator>
				</s:if>
				<s:else>
					<tr>
						<td colspan="11">没有记录</td>
					</tr>
				</s:else>
				</tbody>
				<tfoot>
				<tr>
					<td colspan="11">
						<div>
							<s:if
								test="staffId==null && start==null && end==null && year==null && month==null ">
								<s:if test="page.currentPage != 1">
									<input class="firstPage" type="button" value="首页"
										onclick="location.href='findReimburseAll?page.currentPage=1'" />
									<input class="frontPage" type="button" value="上一页"
										onclick="location.href='findReimburseAll?page.currentPage=${page.currentPage - 1}'" />
								</s:if>
								<s:else>
									<input class="firstPage" type="button" value="首页" disabled />
									<input class="frontPage" type="button" value="上一页" disabled />
								</s:else>
								<s:if test="page.currentPage != page.totalPages">
									<input class="secondPage" type="button" value="下一页"
										class="lastPage" onclick="location.href='findReimburseAll?page.currentPage=${page.currentPage + 1}'" />
									<input type="button" value="尾页"
										onclick="location.href='findReimburseAll?page.currentPage=${page.totalPages}'" />
								</s:if>
								<s:else>
									<input class="secondPage" type="button" value="下一页" disabled />
									<input class="lastPage" type="button" value="尾页" disabled />
								</s:else>
							</s:if>
							<s:elseif
								test="staffId!=null && start==null && end==null && year==null && month==null ">
								<s:if test="page.currentPage != 1">
									<input type="button" value="首页"
										onclick="location.href='findReimburseById?page.currentPage=1&staffId=${staffId}'" />
									<input type="button" value="上一页"
										onclick="location.href='findReimburseById?page.currentPage=${page.currentPage - 1}&staffId=${staffId}'" />
								</s:if>
								<s:else>
									<input type="button" value="首页" disabled />
									<input type="button" value="上一页" disabled />
								</s:else>
								<s:if test="page.currentPage != page.totalPages">
									<input type="button" value="下一页"
										onclick="location.href='findReimburseById?page.currentPage=${page.currentPage + 1}&staffId=${staffId}'" />
									<input type="button" value="尾页"
										onclick="location.href='findReimburseById?page.currentPage=${page.totalPages}&staffId=${staffId}'" />
								</s:if>
								<s:else>
									<input type="button" value="下一页" disabled />
									<input type="button" value="尾页" disabled />
								</s:else>
							</s:elseif>
							<s:elseif
								test="staffId==null && start!=null && end!=null && year==null && month==null ">
								<s:if test="page.currentPage != 1">
									<input type="button" value="首页"
										onclick="location.href='findReimburseByDate?page.currentPage=1&start=<s:date name="start" format="yyyy-MM-dd"/>&end=<s:date name="end" format="yyyy-MM-dd"/>'" />
									<input type="button" value="上一页"
										onclick="location.href='findReimburseByDate?page.currentPage=${page.currentPage - 1}&start=<s:date name="start" format="yyyy-MM-dd"/>&end=<s:date name="end" format="yyyy-MM-dd"/>'" />
								</s:if>
								<s:else>
									<input type="button" value="首页" disabled />
									<input type="button" value="上一页" disabled />
								</s:else>
								<s:if test="page.currentPage != page.totalPages">
									<input type="button" value="下一页"
										onclick="location.href='findReimburseByDate?page.currentPage=${page.currentPage + 1}&start=<s:date name="start" format="yyyy-MM-dd"/>&end=<s:date name="end" format="yyyy-MM-dd"/>'" />
									<input type="button" value="尾页"
										onclick="location.href='findReimburseByDate?page.page.currentPage=${page.totalPages}&start=<s:date name="start" format="yyyy-MM-dd"/>&end=<s:date name="end" format="yyyy-MM-dd"/>'" />
								</s:if>
								<s:else>
									<input type="button" value="下一页" disabled />
									<input type="button" value="尾页" disabled />
								</s:else>
							</s:elseif>
							<s:elseif
								test="staffId==null && start==null && end==null && year!=null && month!=null ">
								<s:if test="page.currentPage != 1">
									<input type="button" value="首页"
										onclick="location.href='findReimburseByMonth?page.currentPage=1&year=${year}&month=${month}'" />
									<input type="button" value="上一页"
										onclick="location.href='findReimburseByMonth?page.currentPage=${page.currentPage - 1}&year=${year}&month=${month}'" />
								</s:if>
								<s:else>
									<input type="button" value="首页" disabled />
									<input type="button" value="上一页" disabled />
								</s:else>
								<s:if test="page.currentPage != page.totalPages">
									<input type="button" value="下一页"
										onclick="location.href='findReimburseByMonth?page.currentPage=${page.currentPage + 1}&year=${year}&month=${month}'" />
									<input type="button" value="尾页"
										onclick="location.href='findReimburseByMonth?page.currentPage=${page.totalPages}&year=${year}&month=${month}'" />
								</s:if>
								<s:else>
									<input type="button" value="下一页" disabled />
									<input type="button" value="尾页" disabled />
								</s:else>
							</s:elseif>
							<span style="margin: 0 80px 0 5px;">${page.currentPage}/${page.totalPages}</span>
							</tfoot>
						</div>
					</td>
				</tr>
			</table>

			
		</div>
	</body>
</html>
